package com.bsoft.ecommerce.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum  GoodsCategory {
    DIAN_QI("10001","电器"),
    JIA_JU("10002","家具"),
    FU_SHI("10003","服饰"),
    MY_YIN("10004","母婴"),
    SHI_PIN("10005","食品"),
    TU_SHU("10006","图书");
    private final String code;

    private final String description;

    public static  GoodsCategory of(String code){
        Objects.requireNonNull(code);

        return Stream.of(values())
                .filter(bean->bean.code.equals(code))
                .findAny()
                .orElseThrow(
                        ()->new IllegalArgumentException(code+"not is find")
                );
    }
}
